# Setting batch to true, triggers one build at a time.
# if there is a push while a build in progress, it will wait,
# until the running build finishes, and produce a build with all the changes
# that happened during the last build.
trigger:
  batch: true
  branches:
    include:
    - feature/*
  paths:
    include:
    - '*'
    exclude:
    - '**.md'
    - eng/Version.Details.xml
    - .devcontainer/*
    - .github/*
    - docs/*
    - LICENSE.TXT
    - PATENTS.TXT
    - THIRD-PARTY-NOTICES.TXT

pr:
  branches:
    include:
    - feature/*
  paths:
    include:
    - '*'
    exclude:
    - '**.md'
    - eng/Version.Details.xml
    - .devcontainer/*
    - .github/*
    - docs/*
    - LICENSE.TXT
    - PATENTS.TXT
    - THIRD-PARTY-NOTICES.TXT

variables:
  - template: /eng/pipelines/common/variables.yml
  - ${{ if and(ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest')) }}:
    - name: TeamName
      value: dotnet-core

extends:
  template:  /eng/pipelines/common/templates/pipeline-with-resources.yml
  parameters:
    stages:
    - stage: Build
      jobs:
        - ${{ if ne(variables.isOfficialBuild, true) }}:
          #
          # Build the whole product with Checked CoreCLR and run runtime tests
          #
          - template: /eng/pipelines/common/platform-matrix.yml
            parameters:
              jobTemplate: /eng/pipelines/common/global-build-job.yml
              helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
              buildConfig: checked
              platforms:
              - linux_x64
              - windows_x64
              jobParameters:
                timeoutInMinutes: 200
                buildArgs: -s clr+libs+hosts+packs -c debug -rc $(_BuildConfig)
                postBuildSteps:
                  - template: /eng/pipelines/common/templates/runtimes/build-runtime-tests-and-send-to-helix.yml
                    parameters:
                      creator: dotnet-bot
                      testRunNamePrefixSuffix: CoreCLR_$(_BuildConfig)

          #
          # Build the whole product with Release CoreCLR and run libraries tests
          #
          - template: /eng/pipelines/common/platform-matrix.yml
            parameters:
              jobTemplate: /eng/pipelines/common/global-build-job.yml
              helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
              buildConfig: release
              platforms:
              - linux_x64
              - windows_x64
              jobParameters:
                timeoutInMinutes: 180
                buildArgs: -s clr+libs+libs.tests+hosts+packs -c $(_BuildConfig) /p:ArchiveTests=true
                postBuildSteps:
                  - template: /eng/pipelines/libraries/helix.yml
                    parameters:
                      creator: dotnet-bot
                      testRunNamePrefixSuffix: Libraries_$(_BuildConfig)

          #
          # Build and test libraries AllConfigurations
          #
          - template: /eng/pipelines/common/platform-matrix.yml
            parameters:
              jobTemplate: /eng/pipelines/common/global-build-job.yml
              buildConfig: ${{ variables.debugOnPrReleaseOnRolling }}
              platforms:
              - windows_x64
              jobParameters:
                buildArgs: -test -s tools+libs+libs.tests -allConfigurations -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
                nameSuffix: Libraries_AllConfigurations
                timeoutInMinutes: 150

        - ${{ else }}:
          #
          # Build the whole product with Release CoreCLR
          #
          - template: /eng/pipelines/common/platform-matrix.yml
            parameters:
              jobTemplate: /eng/pipelines/common/global-build-job.yml
              helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
              buildConfig: release
              platforms:
              - linux_x64
              - windows_x64
              jobParameters:
                isOfficialBuild: true
                timeoutInMinutes: 180
                buildArgs: -s clr+libs+hosts+packs -c $(_BuildConfig)
                postBuildSteps:
                  # Upload the results.
                  - template: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
                    parameters:
                      name: $(osGroup)$(osSubgroup)_$(archType)

          #
          # Build libraries AllConfigurations for packages
          #
          - template: /eng/pipelines/common/platform-matrix.yml
            parameters:
              jobTemplate: /eng/pipelines/common/global-build-job.yml
              buildConfig: Release
              platforms:
              - windows_x64
              jobParameters:
                buildArgs: -s tools+libs -allConfigurations -c $(_BuildConfig) /p:TestAssemblies=false /p:TestPackages=true
                nameSuffix: Libraries_AllConfigurations
                isOfficialBuild: true
                postBuildSteps:
                  - template: /eng/pipelines/common/upload-intermediate-artifacts-step.yml
                    parameters:
                      name: Libraries_AllConfigurations
                timeoutInMinutes: 95

    - ${{ if eq(variables.isOfficialBuild, true) }}:
      - template: /eng/pipelines/official/stages/publish.yml
        parameters:
          isOfficialBuild: true